<?php


namespace app\api\common\member;

class Helper
{
	public static function SigningReward($user, $rule, $field, $gift_data, &$gift_info)
	{
		$remarks = "";
		if ($rule == "ordinary") {
			if ($field == "daily") {
				$remarks = "日常签到奖励获得";
			} elseif ($field == "first") {
				$remarks = "首次签到奖励获得";
			}
		}
		if ($rule == "continuity") {
			$remarks = "连续签到{$field}次领取奖励获得";
		}
		if ($rule == "total") {
			$remarks = "累计签到{$field}次领取奖励获得";
		}
		if ($rule == "special") {
			$remarks = "特定日期签到奖励获得";
		}
		if (!empty($gift_data["viptime"]["value"]) && isset($gift_data["viptime"]["type"]) && $user["is_forever_vip"] != 1) {
			$viptime = \app\common\helper\Time::computing_time($gift_data["viptime"]["type"], $gift_data["viptime"]["value"], $user["viptime"]);
			$gift_info["viptime"] += $gift_data["viptime"]["value"];
			Finance::set($user["id"], "viptime", $viptime, 0, $remarks, \app\common\model\MemberAppModel::UserVipTimeLogSourceSignIngGive);
		}
		if (!empty($gift_data["point"])) {
			$gift_info["point"] += $gift_data["point"];
			Finance::set($user["id"], "point", $gift_data["point"], 0, $remarks, \app\common\model\MemberAppModel::UserPointLogSourceSignIngGive);
		}
		if (!empty($gift_data["growth"])) {
			$gift_info["growth"] += $gift_data["growth"];
			Finance::set($user["id"], "growth", $gift_data["growth"], 0, $remarks, \app\common\model\MemberAppModel::UserGrowthLogSourceSignIngGive);
		}
	}
}